var spanUserName = null, spanAmount = null, spanAmountUsed = null, spanAmountLave = null;
function getUserInfo() {
    $.post("/Ajax.aspx?oper=getuserinfo", {}, function(data) {        
        if (data == "")
            return;
        var tempdata = null;
        eval("tempdata=" + data);
        if (tempdata == null || tempdata.length != 6)
            return;
        var changed = false;
        var pos = 0;
        if (userInfo.ID != tempdata[pos]) {
            userInfo.ID = tempdata[pos];
            changed = true;
        }
        pos++;
        if (userInfo.UserName != tempdata[pos]) {
            userInfo.UserName = tempdata[pos];
            changed = true;
        }
        pos++;
        if (userInfo.Amount != tempdata[pos]) {
            userInfo.Amount = tempdata[pos];
            changed = true;
        }
        pos++;
        if (userInfo.AmountUsed != tempdata[pos]) {
            userInfo.AmountUsed = tempdata[pos];
            changed = true;
        }
        pos++;
        if (userInfo.BackPct != tempdata[pos]) {
            userInfo.BackPct = tempdata[pos];
            changed = true;
        }
        pos++;
        if (userInfo.Aid != tempdata[pos]) {
            userInfo.Aid = tempdata[pos];
            changed = true;
        }
        if (changed && userInfo.Changed)
            userInfo.Changed();
    });
}
function UserInfo() {
    getUserInfo();
    //setInterval(getUserInfo, 5000);
}
UserInfo.prototype = {
    ID: -1,
    UserName: "",
    Amount: 0,
    AmountUsed: 0,
    AmountLave: function() { return this.Amount - this.AmountUsed; },
    BackPct: 0,
    Aid: 9999999999999,
    Changed: function() {
        if (spanUserName) {
            //spanUserName.innerHTML = this.UserName;
            //spanAmount.innerHTML = this.Amount.toFixed(2);
            //spanAmountUsed.innerHTML = this.AmountUsed.toFixed(2);
            //spanAmountLave.innerHTML = this.AmountLave().toFixed(2);
        }
    }
}
var userInfo = new UserInfo();
$(function() {
    spanUserName = document.getElementById("spanUserName");
    spanAmount = document.getElementById("spanAmount");
    spanAmountUsed = document.getElementById("spanAmountUsed");
    spanAmountLave = document.getElementById("spanAmountLave");
    userInfo.Changed();
});

function changeBankInfo() { 
    document.mybank_form.target="_blank" //也可以是_self,_top,_parent,默认为_self 
	document.mybank_form.action="myBankSave.wss";
	document.mybank_form.submit();  
};  
  
function dellower(userid) {
    $j("#div_dialog_confirm").dialog("option", "title", "确认删除");
    $j("#div_dialog_confirm").dialog("option", "buttons", { "确认": function () {
        $j("#div_dialog_confirm").dialog("option", "title", "处理中......");
        $j("#div_dialog_confirm").dialog("option", "buttons", "");
        $j("#div_dialog_confirm").html(htmlload); 
        $.post("ajax_lowerdel.aspx", { lowerid: userid }, completeLowerDel);
    }, "取消": function () { $(this).dialog("close"); }
    }); 
    $j("#div_dialog_confirm").html("账号是否删除?");
    $j("#div_dialog_confirm").dialog("open"); 
}
var htmlload = "<table style='width:100%;height:100%;'><tr><td style='text-align:center;background-color:transparent;'><img src='./public/user_images/bigloading.gif' alt=''/></td></tr></table>";

function completeLowerDel(data) {
    if (data == "") {
        showErrorMsg("删除失败");
        return;
    }
    var result;
    eval("result=" + data);
    if (!result) {
        showErrorMsg("删除失败");
        return;
    }
    if (result.status) {
        reloadData();
        $("#div_dialog_confirm").dialog("close");
    }
    else {
        showErrorMsg(result.msg);
    }
}